﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>修改商品</title>
    <link rel="stylesheet" type="text/css" href="/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/Style/main.css">
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
</head>
<body style="height:100%;">
    <form id="form1" class="easyui-form" action="/api/Goods/Edit" method="post" data-options="novalidate:true">
        <input id="GoodID" name="GoodID" type="hidden" value="">
        <table class="tb60" border="0" cellpadding="0" cellspacing="0">
            <tr class="tr60">
                <td class="td80">商品名称：</td>
                <td colspan="3">
                    <input id="Name" name="Name" type="text" class="easyui-textbox in280"
                           data-options="required:true,validType:'length[3,30]',missingMessage:'必须填写',invalidMessage:'限于3-30个字之间',
                           validateOnCreate:false,validateOnBlur:true">
                    <span class="ft99"> 限于2至30个字之间</span>
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80">拼音编码：</td>
                <td colspan="3">
                    <input id="Pinyin" name="Pinyin" type="text" class="easyui-textbox in180">
                    <span class="ft99"> 拼音简码或助记码</span>
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80">成本价：</td>
                <td class="td20">
                    <input id="PriceCost" name="PriceCost" type="text" value="1" precision="2" class="easyui-numberbox in80">
                    <span class="ft99"> 元</span>
                </td>
                <td class="td80">批发价：</td>
                <td class="td20">
                    <input id="PriceTrade" name="PriceTrade" type="text" value="1" precision="2" class="easyui-numberbox in80">
                    <span class="ft99"> 元</span>
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80">零售价：</td>
                <td class="td20">
                    <input id="PriceRetail" name="PriceRetail" type="text" value="1" precision="2" class="easyui-numberbox in80">
                    <span class="ft99"> 元</span>
                </td>
                <td class="td80">会员价：</td>
                <td class="td20">
                    <input id="PriceMember" name="PriceMember" type="text" value="1" precision="2" class="easyui-numberbox in80">
                    <span class="ft99"> 元</span>
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80">类别：</td>
                <td class="td20">
                    <select id="Category" name="Category" class="easyui-combobox in120">
                        <option value="1">五粮液</option>
                        <option value="2">五粮液</option>
                    </select>
                </td>
                <td class="td80">品牌：</td>
                <td class="td20">
                    <select id="Brand" name="Brand" class="easyui-combobox in120">
                        <option value="1">泸州</option>
                        <option value="2">老窖</option>
                    </select>
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80">编号：</td>
                <td class="td20">
                    <input id="Nocode" name="Nocode" type="text" value="1" class="easyui-textbox in120">
                </td>
                <td class="td80">条码：</td>
                <td class="td20">
                    <input id="Barcode" name="Barcode" type="text" value="1" class="easyui-textbox in120">
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80">最低库存：</td>
                <td class="td20">
                    <input id="MinInv" name="MinInv" type="text" value="1" class="easyui-numberbox in80">
                </td>
                <td class="td80">最高库存：</td>
                <td class="td20">
                    <input id="MaxInv" name="MaxInv" type="text" value="100" class="easyui-numberbox in80">
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80">最小包装：</td>
                <td class="td20">
                    <select id="PackMin" name="PackMin" class="easyui-combobox in80">
                        <option value="1" selected>个</option>
                        <option value="2">箱</option>
                        <option value="3">瓶</option>
                        <option value="4">条</option>
                        <option value="5">盒</option>
                        <option value="6">片</option>
                        <option value="7">包</option>
                        <option value="8">件</option>
                    </select>
                </td>
                <td class="td80">最大包装：</td>
                <td class="td20">
                    <select id="MaxPack" name="MaxPack" class="easyui-combobox in80">
                        <option value="1">个</option>
                        <option value="2" selected>箱</option>
                        <option value="3">瓶</option>
                        <option value="4">条</option>
                        <option value="5">盒</option>
                        <option value="6">片</option>
                        <option value="7">包</option>
                        <option value="8">件</option>
                    </select>
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80">包装系数：</td>
                <td class="td20">
                    <input id="Ratio" name="Ratio" type="text" value="10" class="easyui-textbox in80">
                </td>
                <td class="td80">规格型号：</td>
                <td class="td20">
                    <input id="Spec" name="Spec" type="text" class="easyui-textbox in80">
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80">供应商：</td>
                <td class="td20">
                    <select id="Supplier" name="Supplier" class="easyui-combobox in180">
                        <option value="1" selected>郑州五粮液经三路专营店</option>
                        <option value="2">新郑德力西专营店</option>
                        <option value="3">永辉商贸有限公司</option>
                        <option value="4">人民路格力电器专卖店</option>
                    </select>
                </td>
                <td class="td80">生产商：</td>
                <td class="td20">
                    <select id="Producter" name="Producter" class="easyui-combobox in180">
                        <option value="1" selected>阳光电源股份有限公司</option>
                        <option value="2">泸州老窖股份有限公司</option>
                        <option value="3">中粮集团</option>
                        <option value="4">珠海格力电器股份有限公司</option>
                    </select>
                </td>
            </tr>
            <tr class="tr120">
                <td class="td80">说明：</td>
                <td colspan="3"><input id="Desc" name="Desc" type="text" multiline="true" class="easyui-textbox" style="width:480px;height:120px"></td>
            </tr>
            <tr class="tr60">
                <td class="td80">添加时间：</td>
                <td class="td20">
                    <input id="AddTime" name="AddTime" type="text" value="" class="easyui-textbox in120">
                </td>
                <td class="td80">最后修改：</td>
                <td class="td20">
                    <input id="LastTime" name="LastTime" type="text" value="" class="easyui-textbox in120">
                </td>
            </tr>
            <tr class="tr60">
                <td class="td80"></td>
                <td class="td20">
                    <a href="#" class="easyui-linkbutton btn" onclick="submitForm()" iconCls="icon-save" style="color: #009900;width:80px">保 存</a>
                </td>
                <td class="td80"></td>
                <td class="td20">
                    <a href="#" class="easyui-linkbutton btn" iconCls="icon-cancel" style="color: #009900;width:80px">取 消</a>
                </td>
            </tr>
        </table>
    </form>
    <script type="text/javascript" src="/Scripts/common.js"></script>
    <script type="text/javascript" src="/Scripts/pinyin_dict_firstletter.js"></script>
    <script type="text/javascript" src="/Scripts/pinyinUtil.js"></script>
    <script type="text/javascript">
        $(function () {
            getGoods();
            getPinYin();
        });

        function getGoods()
        {
            var sID = getQueryString();
            $("#GoodID").val(sID.ID);
            var sUrl = "/api/Goods/Get/" + sID.ID;
            $.ajax({
                url: sUrl,
                type: "get",
                dataType: "json",
                success: function (data) {
                    var da = $.parseJSON(data);
                    $('#Name').textbox('setValue', da[0].Name);
                    $('#Pinyin').textbox('setValue', da[0].Pinyin);
                    $('#PriceCost').textbox('setValue', da[0].PriceCost);
                    $('#PriceTrade').textbox('setValue', da[0].PriceTrade);
                    $('#PriceRetail').textbox('setValue', da[0].PriceRetail);
                    $('#PriceMember').textbox('setValue', da[0].PriceMember);
                    $('#Category').combobox('setValue', da[0].Category);
                    $('#Brand').combobox('setValue', da[0].Brand);
                    $('#Nocode').textbox('setValue', da[0].Nocode);
                    $('#Barcode').textbox('setValue', da[0].Barcode);
                    $('#MinInv').textbox('setValue', da[0].InvMin);
                    $('#MaxInv').textbox('setValue', da[0].InvMax);
                    $('#PackMin').textbox('setValue', da[0].PackMin);
                    $('#MaxPack').textbox('setValue', da[0].PackMax);
                    $('#Ratio').textbox('setValue', da[0].PackRatio);
                    $('#Spec').textbox('setValue', da[0].PackSpec);
                    $('#Supplier').combobox('setValue', da[0].Supplier);
                    $('#Producter').combobox('setValue', da[0].Producter);
                    $('#Desc').textbox('setValue', da[0].Desc);
                    $('#AddTime').textbox('setValue', da[0].AddTime);
                    $('#LastTime').textbox('setValue', da[0].LastTime);
                },
                error: function (msg) {
                    alert("很抱歉，未能获取相关信息，请稍候重试。或与技术人员联系。" + msg.statusText);
                }
            });
        }

        function getPinYin() {
            $('#Name').textbox({
                onChange: function (value) {
                    var name = value;
                    var pinyin = pinyinUtil.getFirstLetter(name);
                    $("#Pinyin").textbox('setValue', pinyin);
                }
            });
        }

        function submitForm() {
            $('#form1').form('submit', {
                onSubmit: function () {
                    return $(this).form('enableValidation').form('validate');
                },
                success: function (data) {
                    var oJson = JSON.parse(data);
                    if (oJson == 0) {
                        alert(sMsgErrorGet);
                    }
                    if (oJson == 1) {
                        alert("商品修改成功。");
                        //$.messager.alert('成功', '商品修改成功。', 'info');
                        window.parent.closeThisTab();  
                    }
                }
            });
        }

    </script>
    <script type="text/javascript" src="/easyui/locale/easyui-lang-zh_CN.js"></script>

</body>
</html>
